# 数组二分查找
import random
from random import randint
import bisect

lst = []
SIZE = 10
random.seed(5)
for _ in range(SIZE):
    item = randint(1, SIZE)
    bisect.insort(lst, item)
    print('%2d ->' % item, lst)


# 用于数字表查询
def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
    i = bisect.bisect(breakpoints, score)
    return grades[i]


grade = [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
print(grade)
